package com.vinaprime.primeschedule.presentation;

import java.io.File;

import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.util.Log;
import android.widget.Toast;
	
public class ApplicationInformation extends Activity {
	private Context myContext;
	
	public ApplicationInformation(Context contex){
		this.myContext = contex;
	}
	
	public String getDBPath (){
		PackageManager pm = myContext.getPackageManager();
		String path = "";
		
		try
		{
			PackageInfo pi = pm.getPackageInfo(this.myContext.getPackageName(), 0);
			path = pi.applicationInfo.dataDir;
			path = path + "/";
		}
		catch(NameNotFoundException e)
		{
			Log.w("yourtag", "Error Package name not found ", e);
		}
		
		return path;
	}
	
	public void preparePath()
	{
		String path = getDBPath();
		File folderImage = new File(path + "images");
		File folderImgEvent = new File(path + "images/events");
		File folderImgSound = new File(path + "images/sounds");
		
		try{
			if(!folderImage.exists()){
	    		folderImage.mkdir();
	    	}
			
			if(!folderImgEvent.exists()){
				folderImgEvent.mkdir();
	    	}
			
			if(!folderImgSound.exists()){
				folderImgSound.mkdir();
	    	}
		}
		catch(Exception ex){
			ex.getMessage();
		}
		
	}
}
